{{- /*

*/ -}}

{{ $title := ((.Get 0) | default (printf "Accordion Item #%d" (.Ordinal))) }}
{{ $id := ((printf "sc-%s-%s" ($.Name) (delimit (shuffle (seq 11 99)) "")) | md5) }}

{{ if (and (ne (.Parent) nil) (eq (.Parent.Name) "accordion")) }}
    {{ $pid := ((printf "sc-%s-%d" (.Parent.Name) (.Parent.Ordinal)) | md5) }}
    <div class="accordion-item">
      <div class="accordion-header">
        <a class="accordion-button collapsed" href="#" role="button" tabindex="0"
           data-bs-toggle="collapse" data-bs-target="#sc-{{ ($id) }}"
           aria-expanded="false" aria-controls="sc-{{ ($id) }}" aria-label="{{ ($title) }}">
            {{ ($title) }}
        </a>
      </div>
      <div class="accordion-collapse collapse" id="sc-{{ ($id) }}" data-bs-parent="#sc-{{ ($pid) }}">
        <div class="accordion-body">
            {{ with (.Inner) }}{{ (. | $.Page.RenderString (dict "display" "block")) }}{{ end }}
        </div>
      </div>
    </div>
{{ else }}
  <div class="accordion mb-3 shortcode shortcode-{{ ($.Name) }}">
    <div class="accordion-item">
      <div class="accordion-header">
        <a class="accordion-button collapsed" href="#" role="button"
           data-bs-toggle="collapse" data-bs-target="#sc-{{ ($id) }}"
           aria-expanded="false" aria-controls="sc-{{ ($id) }}" aria-label="{{ ($title) }}">
            {{ ($title) }}
        </a>
      </div>
      <div class="accordion-collapse collapse" id="sc-{{ ($id) }}">
        <div class="accordion-body">
            {{ with (.Inner) }}{{ (. | $.Page.RenderString (dict "display" "block")) }}{{ end }}
        </div>
      </div>
    </div>
  </div>
{{ end }}
